/*
 * senum.c
 *
 *  Created on: 2013-5-20
 *      Author: xkaying
 */

#include "senum.h"

typedef struct _senumitem{
		char *name;
		char *value;
}SEnumItem;

struct _senum{
		int prority;
		char *name;
		List *item;
};

SEnumItem *SEnumItemInit(char *name)
{
	SEnumItem *pitem;
	pitem=(SEnumItem*)malloc(sizeof(SEnumItem));
	pitem->name=name;
	pitem->value=0;
	return pitem;
}

SEnum *SEnumInit(int prority)
{
	SEnum *penum;
	penum=(SEnum*)malloc(sizeof(SEnum));
	penum->prority=prority;
	penum->name=0;
	penum->item=0;
	return penum;
}
void SEnumAppend(SEnum *penum,char *name)
{
	assert(penum);
	assert(name);
	penum->name=name;
}
void SEnumItemName(SEnum *penum,char *name)
{
	assert(penum);
	assert(name);
	SEnumItem *pitem;
	pitem=SEnumItemInit(name);
	if(penum->item==0){
		penum->item=ListInit();
	}
	ListPush(penum->item,pitem);
}
void SEnumItemValue(SEnum *penum,char *value)
{
	assert(penum);
	assert(penum->item);
	assert(value);
	SEnumItem *pitem;
	pitem=(SEnumItem*)ListEnd(penum->item);
	pitem->value=value;
}
